package com.xxadmin.common.exception;


import com.xxadmin.common.exception.errorcode.ApplicationErrorCodeEnum;

/**
 * 系统应用程序自定义异常
 *
 * @author:chenming
 * @date:2018/4/25
 */
public class ApplicationException extends RuntimeException{

    protected String errorCode;

    protected String errorMessage;

    public ApplicationException(String errorMessage){
        super(errorMessage);

        this.errorMessage = errorMessage;
    }

    public ApplicationException(String errorCode, String errorMessage){
        super(errorMessage);

        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public ApplicationException(String errorMessage,Exception e){
        super(errorMessage,e);

        this.errorMessage = errorMessage;
    }

    public ApplicationException(String errorCode, String errorMessage,Exception e){
        super(errorMessage,e);

        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public ApplicationException(ApplicationErrorCodeEnum applicationErrorCodeEnum){
        this(applicationErrorCodeEnum.getCode(),applicationErrorCodeEnum.getMessage());
    }


    public ApplicationException(ApplicationErrorCodeEnum applicationErrorCodeEnum,Exception e){
        this(applicationErrorCodeEnum.getCode(),applicationErrorCodeEnum.getMessage(),e);
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }
}
